'use strict'

class get {
    constructor() {
        this.param = '/:tag'
    }

    async get(c) {
        //c.param是一个对象，其中的key值是路由参数的名称。
        let tag = c.param.tag
        let reta
        switch (tag) {
            case 'music':
                reta = await c.service.psql.query('select * from music order by music_id asc')
                c.send(reta.rows)
                break;
            case 'video':
                reta = await c.service.psql.query('select * from video order by video_id asc')
                c.send(reta.rows)
                break;
            case 'joke':
                reta = await c.service.psql.query('select * from joke order by joke_id asc')
                c.send(reta.rows)
                break;
            default:
                break;
        }
    }

}

module.exports = get